#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[200005];
int cnt[200005];

signed main() {
	int n, m;
	cin >> n >> m;

	int ans = 0;
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
		ans += cnt[a[i] % m];
		cnt[a[i] % m]++;
	}
	cout << ans;
	return 0;
}
